package com.wangxiang.sys.manage.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import com.wangxiang.common.utils.PageEntity;
import com.wangxiang.sys.manage.feign.ProductFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wangxiang.sys.manage.entity.AuditEntity;
import com.wangxiang.sys.manage.service.AuditService;
import com.wangxiang.common.utils.PageUtils;
import com.wangxiang.common.utils.R;



/**
 * 
 *
 * @author wangxiang
 * @email 2293672863@qq.com
 * @date 2022-04-19 14:35:03
 */
@RestController
@RequestMapping("sys/audit")
public class AuditController {
    @Autowired
    private AuditService auditService;
    @Autowired
    ProductFeign productFeign;

    /**
     * 远程接口调用
     * @param map
     * @return
     */
    @RequestMapping("add")
    public int add(@RequestBody HashMap<String , Integer> map){
        int add = auditService.add(map);
        return add;
    }
    @RequestMapping("page")
    public R page(@RequestBody HashMap<String , Integer> map){
//        System.out.println("map"+map);
        PageEntity pageEntity = auditService.page(map);
        List<HashMap<String, Object>> list = auditService.pageList((List<AuditEntity>) pageEntity.getList());
        for (HashMap<String, Object> stringObjectHashMap : list) {
//            System.out.println(stringObjectHashMap);
        }
        List<HashMap<String, Object>> auditshop = productFeign.auditshop(list);
        return R.ok().put("list",auditshop).put("page",pageEntity);
    }

}
